package com.ojoin.trade.supplyloan_core.web.dao.impl;

import com.ojoin.trade.common.exception.BusinessException;
import com.ojoin.trade.common.exception.DaoException;
import com.ojoin.trade.common.web.dao.impl.BaseDaoImpl;
import com.ojoin.trade.supplyloan_core.web.dao.TbSlCreditControllDao;
import com.ojoin.trade.supplyloan_core.web.domain.TbSlCreditControll;
import org.springframework.stereotype.Repository;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 16-4-11
 * Time: 下午3:37
 * To change this template use File | Settings | File Templates.
 */
@Repository
public class TbSlCreditControllDaoImpl extends BaseDaoImpl<TbSlCreditControll> implements TbSlCreditControllDao {
    @Override
    public void update(Map<String, Object> map) throws BusinessException {
        String mapMethodName = "update";
        try{
            this.sqlSessionTemplate.update(getSqlName(mapMethodName),map);
        }catch (Exception e) {
            throw new DaoException(String.format("更新用户的申请贷款版本控制记录出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }


    }

    @Override
    public TbSlCreditControll queryTbSlCreditControll(Integer id_of_merchant) throws BusinessException {
        String mapMethodName="selectVoByJoinid";
        try{
          return  this.sqlSessionTemplate.selectOne(getSqlName(mapMethodName), id_of_merchant);
        }catch (Exception e) {
            throw new DaoException(String.format("查询用户的申请贷款版本控制记录出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
    }

    @Override
    public void lockById(int id) throws BusinessException {
        String mapMethodName = "lockid";

        try {
            this.sqlSessionTemplate.selectOne(getSqlName(mapMethodName),
                    id);
        } catch (Exception e) {
            throw new DaoException(String.format("加锁出错->" + id + "出错！语句：%s",
                    getSqlName(mapMethodName)), e);
        }
    }


}
